import sys
import csv
import codecs
import settings
from django.core.management import setup_environ
setup_environ(settings)
from contest.models import Competitor, Category, Slope
import os
file = open(os.path.join(os.path.dirname(__file__), '..', "contest.csv"))
reader = csv.reader(file,delimiter=',', quotechar='"')
x = 1

try:
    for i in range(1,62,1):
        print i
        Slope.objects.get_or_create(number=1)
except:
    raise

#for row in reader:
#    try:
#        surname = row[0]#.encode("utf-8")
#        name = row[1]#.encode("utf-8")
#        year = row[2]#.encode("utf-8")
#        male = row[3]#.encode("utf-8") == 'X'
#        category_name = row[5]#.encode("utf-8")
#        Category.objects.get_or_create(name=category_name)
#        category = Category.objects.get(name=category_name)
#        competitor = Competitor.objects.get_or_create(name=name,surname=surname,category=category, number=x)
#        print x, competitor, category
#        # 
#        x = x + 1
#
#    except:
#        import pdb; pdb.set_trace()
#        raise